package com.first.teacher.controller;

import com.first.common.pojo.EduTeacher;
import com.first.common.util.OssUtil;
import com.first.common.util.VerificationUtil;
import com.first.common.vo.Result;
import com.first.teacher.service.TeacherService;
import com.first.teacher.vo.TeacherVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: first-project
 * @description:
 * @author: 马英贤
 * @create: 2023-06-05 15:14
 **/
@RestController
@RequestMapping("/core/recruitment")
@Api(tags = "讲师招募类")
public class recruitmentController {
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private TeacherService teacherService;

    @ApiOperation(value = "讲师招募接口")
    @PostMapping("/qianaddTeacher")
    public Result qianaddTeacher(@RequestBody EduTeacher eduTeacher){
        String s = teacherService.increaseTeacher(eduTeacher);
        if (s.equals("2")){
            return Result.fail("你已提交过审核");
        }else if (s.equals("1")){
            return Result.fail("你已是讲师");
        }else if (s.equals("0")){
            return Result.fail("姓名已重复");
        }
        return Result.success("添加成功",null);
    }

    @ApiOperation(value = "上传讲师头像")
    @PostMapping("/uploadMsg")
    public String uploadMsg(@RequestParam MultipartFile file){
        String upload = OssUtil.uploadFile(file);
        return upload;
    }

    @ApiOperation("验证码获取")
    @GetMapping("/getYanZhengMa/{mobile}")
    public Result getYanZhengMa(@PathVariable String mobile){
        return teacherService.getYanZhengMa(mobile);
    }

}
